<script setup>
	import { onMounted, reactive, ref } from 'vue';
	import { onShow } from "@dcloudio/uni-app"
	import { uniFetch } from '../../utils/fetch';
	onShow(() => {
		getdata()
		getdata2()
	})
	const user = ref({});
	const mount=ref({})
	const getdata = () => {
		uniFetch({
			url: "/driver/users"
		}).then(res => {
			console.log(res, "res");
			if(res.data.code !==200){
				return uni.utils.toast("数据加载失败")
			}else{
							user.value = res.data.data
			}

		})

	}
	const getdata2 = () => {
		uniFetch({
			url: "/driver/users/taskReport",
			data:{
				year:new Date().getFullYear(),
				month:new Date().getMonth()+1
			}
		}).then(res => {
			console.log(res, "res1");
			if(res.data.code !==200){
				return uni.utils.toast("数据加载失败")
			}else{
			mount.value=res.data.data
			}
			// user.value=res.data.data
		})
	}
</script>

<template>
	<view class="page-container">
		<view class="user-profile">
			<image class="avatar" :src="user.avatar" mode=""></image>
			<text class="username">{{user.name}}</text>
			<text class="no">司机编号：{{user.number}}</text>
			<text class="mobile">手机号码：{{user.phone}}</text>
		</view>
		<view class="month-overview">
			<view class="title">我的任务</view>
			<view class="content">
				<view class="item">
				<text class="volumn">{{mount.taskAmounts}}</text>
					<text class="label">任务总量</text>
				</view>
				<view class="item">
					<text class="volumn">{{mount.completedAmounts}}</text>
					<text class="label">完成任务量</text>
				</view>
				<view class="item">
					<text class="volumn">{{mount.transportMileage}}</text>
					<text class="label">运输里程(km)</text>
				</view>
			</view>
		</view>
		<view class="entry-list">
			<uni-list :border="false">
				<uni-list-item to="/subpkg_user/truck/index" showArrow title="车辆信息" />
				<uni-list-item to="/subpkg_user/task/index" showArrow title="任务数据" />
				<uni-list-item to="/subpkg_user/settings/index" showArrow title="系统设置" />
			</uni-list>
		</view>
	</view>
</template>

<style lang="scss" scoped>
	@import './index.scss';
</style>